Talk:Stairs create unknown sector types

I was testing the bug, modifying code in order to always reproduce it, and I found that the type field should be donutChange, and not lowerAndChange. Since the thinker assigned is T_MoveFloor, this thinker only works with types donutRaise and lowerAndChange and ignores others.

And there is a direction check that makes donutRaise only work when the direction of the sector direction is up, and lowerAndChange when it's down. So, because in doom stairs can only be built upwards, the only type that allows the bug to happen is donutRaise.

(p_floor.c:237)

Now let's talk about probabilities, which are not correct: (this is a work in progress) Probabilities depend on many factors of the game like what else used the shared memory before. Keeping that in mind, let's do an analysis supposing that initial values are actually random, for the sake of convinience.

The probabilities of encountering an illegal stair step are linearly proportional to the number of steps. For each step:

First, the type should be donutChange.

The "type" variable is of type enum, and this is a problem since it's size depends on compiler flags and other variables. But its size should be less than an int(2^32) and bigger than a char(2^8). Since it's usual that the compiler decides to use type int for enums, and that the bug doesn't appear that often, it's probable that it is an int.

So, this cuts down the probability to 1/(2^32).

Then, the texture should be rendered without errors. The "Texture" variable is of type short (2^16) and the numbers that I tested that work are in range 0 to 156 (number of flats in wad), but then -356 and many other numbers work. The majority of numbers make a crash with the error "W_CacheLumpNum %i >= numlumps". What's happening is that you musn't exceed the number of lumps in the wad (doom2: 2919, doom1:2306). Rendering a non-flat lump doesn't crash.

So, after an illegal step was formed, there is a chance of (2^16 - 2919)/(2^16) (for doom 2) that looking at that step would inmediately crash the game.

Only if it didn't crash, then, player must step on the step and its type should be illegal. Probabilities of a ""P_PlayerInSpecialSector: "unknown special %i"" crash here are (2^16 - 6)/(2^16).

--DualSaaZ (talk) 22:48, 3 February 2023 (CST)

texture crashes
Of course that my analysis of the texture loading error "W_CacheLumpNum > numlumps", and its probabilities is incomplete, it requires more study. So the only table values I'm sure are ok, are the "nothing happens (no donutChange)" ones.

--DualSaaZ (talk) 18:22, 3 February 2023 (CST)